home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / GraphicsCards / StormMesa / src / texstate.c < prev    next >
C/C++ Source or Header  |  1999-02-04  |  32KB  |  1,220 lines

  1. /* $Id: texstate.c,v 3.11 1998/08/21 01:50:14 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.0
  6.  * Copyright (C) 1995-1998  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: texstate.c,v $
  26.  * Revision 3.11  1998/08/21 01:50:14  brianp
  27.  * made max_texture_coord_sets() non-static
  28.  *
  29.  * Revision 3.10  1998/07/18 03:35:28  brianp
  30.  * get of GL_TEXTURE_INTERNAL_FORMAT wasn't handled
  31.  *
  32.  * Revision 3.9  1998/06/17 01:21:06  brianp
  33.  * include assert.h
  34.  *
  35.  * Revision 3.8  1998/06/07 22:18:52  brianp
  36.  * implemented GL_EXT_multitexture extension
  37.  *
  38.  * Revision 3.7  1998/04/20 23:55:13  brianp
  39.  * applied DavidB's changes for v0.25 of 3Dfx driver
  40.  *
  41.  * Revision 3.6  1998/03/27 04:17:31  brianp
  42.  * fixed G++ warnings
  43.  *
  44.  * Revision 3.5  1998/03/15 17:55:03  brianp
  45.  * fixed a typo in gl_update_texture_state()
  46.  *
  47.  * Revision 3.4  1998/02/20 04:53:37  brianp
  48.  * implemented GL_SGIS_multitexture
  49.  *
  50.  * Revision 3.3  1998/02/04 05:00:07  brianp
  51.  * added a few casts for Amiga StormC compiler
  52.  *
  53.  * Revision 3.2  1998/02/03 04:27:54  brianp
  54.  * added texture lod clamping
  55.  *
  56.  * Revision 3.1  1998/02/01 19:39:09  brianp
  57.  * added GL_CLAMP_TO_EDGE texture wrap mode
  58.  *
  59.  * Revision 3.0  1998/01/31 21:04:38  brianp
  60.  * initial rev
  61.  *
  62.  */
  63.  
  64.  
  65. #ifdef PC_HEADER
  66. #include "all.h"
  67. #else
  68. #include <assert.h>
  69. #include "context.h"
  70. #include "macros.h"
  71. #include "matrix.h"
  72. #include "texobj.h"
  73. #include "texstate.h"
  74. #include "texture.h"
  75. #include "types.h"
  76. #include "xform.h"
  77. #endif
  78.  
  79.  
  80.  
  81. #ifdef SPECIALCAST
  82. /* Needed for an Amiga compiler */
  83. #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
  84. #define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
  85. #else
  86. /* all other compilers */
  87. #define ENUM_TO_FLOAT(X) ((GLfloat)(X))
  88. #define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
  89. #endif
  90.  
  91.  
  92.  
  93. /*
  94.  * Return max number of simultaneous textures.
  95.  */
  96. GLint gl_max_texture_coord_sets( const GLcontext *ctx )
  97. {
  98.    if (ctx->Driver.GetParameteri) {
  99.       GLint maxCoordSets = (*ctx->Driver.GetParameteri)(ctx, DD_MAX_TEXTURE_COORD_SETS);
  100.       assert(maxCoordSets >= 1 && maxCoordSets <= MAX_TEX_COORD_SETS);
  101.       return maxCoordSets;
  102.    }
  103.    else {
  104.       return MAX_TEX_COORD_SETS;
  105.    }
  106. }
  107.  
  108.  
  109.  
  110. /**********************************************************************/
  111. /*                       Texture Environment                          */
  112. /**********************************************************************/
  113.  
  114.  
  115. void gl_TexEnvfv( GLcontext *ctx,
  116.           GLenum target, GLenum pname, const GLfloat *param )
  117. {
  118.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  119.  
  120.    if (INSIDE_BEGIN_END(ctx)) {
  121.       gl_error( ctx, GL_INVALID_OPERATION, "glTexEnv" );
  122.       return;
  123.    }
  124.  
  125.    if (target!=GL_TEXTURE_ENV) {
  126.       gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
  127.       return;
  128.    }
  129.  
  130.    if (pname==GL_TEXTURE_ENV_MODE) {
  131.       GLenum mode = (GLenum) (GLint) *param;
  132.       switch (mode) {
  133.      case GL_MODULATE:
  134.      case GL_BLEND:
  135.      case GL_DECAL:
  136.      case GL_REPLACE:
  137.         /* A small optimization for drivers */ 
  138.         if (texSet->EnvMode == mode)
  139.            return;
  140.         texSet->EnvMode = mode;
  141.         break;
  142.      default:
  143.         gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
  144.         return;
  145.       }
  146.    }
  147.    else if (pname==GL_TEXTURE_ENV_COLOR) {
  148.       texSet->EnvColor[0] = CLAMP( param[0], 0.0, 1.0 );
  149.       texSet->EnvColor[1] = CLAMP( param[1], 0.0, 1.0 );
  150.       texSet->EnvColor[2] = CLAMP( param[2], 0.0, 1.0 );
  151.       texSet->EnvColor[3] = CLAMP( param[3], 0.0, 1.0 );
  152.    }
  153.    else if (pname==GL_TEXTURE_ENV_COORD_SET_EXT) {
  154.       GLint p = (GLint) param[0] - GL_TEXTURE0_EXT;
  155.       if (p >= 0 && p < gl_max_texture_coord_sets(ctx)) {
  156.      texSet->TexCoordSet = p;
  157.       }
  158.       else {
  159.      gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
  160.      return;
  161.       }
  162.    }
  163.    else {
  164.       gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
  165.       return;
  166.    }
  167.  
  168.    /* Tell device driver about the new texture environment */
  169.    if (ctx->Driver.TexEnv) {
  170.       (*ctx->Driver.TexEnv)( ctx, pname, param );
  171.    }
  172. }
  173.  
  174.  
  175.  
  176.  
  177.  
  178. void gl_GetTexEnvfv( GLcontext *ctx,
  179.              GLenum target, GLenum pname, GLfloat *params )
  180. {
  181.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  182.    if (target!=GL_TEXTURE_ENV) {
  183.       gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
  184.       return;
  185.    }
  186.    switch (pname) {
  187.       case GL_TEXTURE_ENV_MODE:
  188.      *params = ENUM_TO_FLOAT(texSet->EnvMode);
  189.      break;
  190.       case GL_TEXTURE_ENV_COLOR:
  191.      COPY_4V( params, texSet->EnvColor );
  192.      break;
  193.       case GL_TEXTURE_ENV_COORD_SET_EXT:
  194.      params[0] = (GLfloat) (GL_TEXTURE0_EXT + texSet->TexCoordSet);
  195.       default:
  196.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
  197.    }
  198. }
  199.  
  200.  
  201. void gl_GetTexEnviv( GLcontext *ctx,
  202.              GLenum target, GLenum pname, GLint *params )
  203. {
  204.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  205.    if (target!=GL_TEXTURE_ENV) {
  206.       gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
  207.       return;
  208.    }
  209.    switch (pname) {
  210.       case GL_TEXTURE_ENV_MODE:
  211.      *params = (GLint) texSet->EnvMode;
  212.      break;
  213.       case GL_TEXTURE_ENV_COLOR:
  214.      params[0] = FLOAT_TO_INT( texSet->EnvColor[0] );
  215.      params[1] = FLOAT_TO_INT( texSet->EnvColor[1] );
  216.      params[2] = FLOAT_TO_INT( texSet->EnvColor[2] );
  217.      params[3] = FLOAT_TO_INT( texSet->EnvColor[3] );
  218.      break;
  219.       case GL_TEXTURE_ENV_COORD_SET_EXT:
  220.      params[0] = GL_TEXTURE0_EXT + texSet->TexCoordSet;
  221.       default:
  222.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
  223.    }
  224. }
  225.  
  226.  
  227.  
  228.  
  229. /**********************************************************************/
  230. /*                       Texture Parameters                           */
  231. /**********************************************************************/
  232.  
  233.  
  234. void gl_TexParameterfv( GLcontext *ctx,
  235.             GLenum target, GLenum pname, const GLfloat *params )
  236. {
  237.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  238.    GLenum eparam = (GLenum) (GLint) params[0];
  239.    struct gl_texture_object *texObj;
  240.  
  241.    switch (target) {
  242.       case GL_TEXTURE_1D:
  243.      texObj = texSet->Current1D;
  244.      break;
  245.       case GL_TEXTURE_2D:
  246.      texObj = texSet->Current2D;
  247.      break;
  248.       case GL_TEXTURE_3D_EXT:
  249.      texObj = texSet->Current3D;
  250.      break;
  251.       default:
  252.      gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
  253.      return;
  254.    }
  255.  
  256.    switch (pname) {
  257.       case GL_TEXTURE_MIN_FILTER:
  258.      /* A small optimization */
  259.      if (texObj->MinFilter == eparam)
  260.         return;
  261.  
  262.      if (eparam==GL_NEAREST || eparam==GL_LINEAR
  263.          || eparam==GL_NEAREST_MIPMAP_NEAREST
  264.          || eparam==GL_LINEAR_MIPMAP_NEAREST
  265.          || eparam==GL_NEAREST_MIPMAP_LINEAR
  266.          || eparam==GL_LINEAR_MIPMAP_LINEAR) {
  267.         texObj->MinFilter = eparam;
  268.         ctx->NewState |= NEW_TEXTURING;
  269.      }
  270.      else {
  271.         gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  272.         return;
  273.      }
  274.      break;
  275.       case GL_TEXTURE_MAG_FILTER:
  276.      /* A small optimization */
  277.      if (texObj->MagFilter == eparam)
  278.         return;
  279.  
  280.      if (eparam==GL_NEAREST || eparam==GL_LINEAR) {
  281.         texObj->MagFilter = eparam;
  282.         ctx->NewState |= NEW_TEXTURING;
  283.      }
  284.      else {
  285.         gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  286.         return;
  287.      }
  288.      break;
  289.       case GL_TEXTURE_WRAP_S:
  290.      if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
  291.         texObj->WrapS = eparam;
  292.      }
  293.      else {
  294.         gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  295.         return;
  296.      }
  297.      break;
  298.       case GL_TEXTURE_WRAP_T:
  299.      if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
  300.         texObj->WrapT = eparam;
  301.      }
  302.      else {
  303.         gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  304.         return;
  305.      }
  306.      break;
  307.       case GL_TEXTURE_WRAP_R_EXT:
  308.      if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
  309.         texObj->WrapR = eparam;
  310.      }
  311.      else {
  312.         gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  313.      }
  314.      break;
  315.       case GL_TEXTURE_BORDER_COLOR:
  316.      texObj->BorderColor[0] = CLAMP((GLint)(params[0]*255.0), 0, 255);
  317.      texObj->BorderColor[1] = CLAMP((GLint)(params[1]*255.0), 0, 255);
  318.      texObj->BorderColor[2] = CLAMP((GLint)(params[2]*255.0), 0, 255);
  319.      texObj->BorderColor[3] = CLAMP((GLint)(params[3]*255.0), 0, 255);
  320.      break;
  321.       case GL_TEXTURE_MIN_LOD:
  322.      texObj->MinLod = params[0];
  323.      break;
  324.       case GL_TEXTURE_MAX_LOD:
  325.      texObj->MaxLod = params[0];
  326.      break;
  327.       case GL_TEXTURE_BASE_LEVEL:
  328.      if (params[0] < 0.0) {
  329.         gl_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  330.         return;
  331.      }
  332.      texObj->BaseLevel = (GLint) params[0];
  333.      break;
  334.       case GL_TEXTURE_MAX_LEVEL:
  335.      if (params[0] < 0.0) {
  336.         gl_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
  337.         return;
  338.      }
  339.      texObj->MaxLevel = (GLint) params[0];
  340.      break;
  341.       default:
  342.      gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" );
  343.      return;
  344.    }
  345.  
  346.    texObj->Dirty = GL_TRUE;
  347.    ctx->Texture.AnyDirty = GL_TRUE;
  348.    
  349.    if (ctx->Driver.TexParameter) {
  350.       (*ctx->Driver.TexParameter)( ctx, target, texObj, pname, params );
  351.    }
  352. }
  353.  
  354.  
  355.  
  356. void gl_GetTexLevelParameterfv( GLcontext *ctx, GLenum target, GLint level,
  357.                 GLenum pname, GLfloat *params )
  358. {
  359.    GLint iparam;
  360.    gl_GetTexLevelParameteriv( ctx, target, level, pname, &iparam );
  361.    *params = (GLfloat) iparam;
  362. }
  363.  
  364.  
  365.  
  366. void gl_GetTexLevelParameteriv( GLcontext *ctx, GLenum target, GLint level,
  367.                 GLenum pname, GLint *params )
  368. {
  369.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  370.    struct gl_texture_image *tex;
  371.  
  372.    if (level<0 || level>=MAX_TEXTURE_LEVELS) {
  373.       gl_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
  374.       return;
  375.    }
  376.  
  377.    switch (target) {
  378.       case GL_TEXTURE_1D:
  379.      tex = texSet->Current1D->Image[level];
  380.      if (!tex)
  381.         return;
  382.      switch (pname) {
  383.         case GL_TEXTURE_WIDTH:
  384.            *params = tex->Width;
  385.            break;
  386.         case GL_TEXTURE_COMPONENTS:
  387.            /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
  388.            *params = tex->IntFormat;
  389.            break;
  390.         case GL_TEXTURE_BORDER:
  391.            *params = tex->Border;
  392.            break;
  393.         case GL_TEXTURE_RED_SIZE:
  394.         case GL_TEXTURE_GREEN_SIZE:
  395.         case GL_TEXTURE_BLUE_SIZE:
  396.         case GL_TEXTURE_ALPHA_SIZE:
  397.         case GL_TEXTURE_INTENSITY_SIZE:
  398.         case GL_TEXTURE_LUMINANCE_SIZE:
  399.            *params = 8;  /* 8-bits */
  400.            break;
  401.         case GL_TEXTURE_INDEX_SIZE_EXT:
  402.            *params = 8;
  403.            break;
  404.         default:
  405.            gl_error( ctx, GL_INVALID_ENUM,
  406.              "glGetTexLevelParameter[if]v(pname)" );
  407.      }
  408.      break;
  409.       case GL_TEXTURE_2D:
  410.      tex = texSet->Current2D->Image[level];
  411.      if (!tex)
  412.         return;
  413.      switch (pname) {
  414.         case GL_TEXTURE_WIDTH:
  415.            *params = tex->Width;
  416.            break;
  417.         case GL_TEXTURE_HEIGHT:
  418.            *params = tex->Height;
  419.            break;
  420.         case GL_TEXTURE_COMPONENTS:
  421.            /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
  422.            *params = tex->IntFormat;
  423.            break;
  424.         case GL_TEXTURE_BORDER:
  425.            *params = tex->Border;
  426.            break;
  427.         case GL_TEXTURE_RED_SIZE:
  428.         case GL_TEXTURE_GREEN_SIZE:
  429.         case GL_TEXTURE_BLUE_SIZE:
  430.         case GL_TEXTURE_ALPHA_SIZE:
  431.         case GL_TEXTURE_INTENSITY_SIZE:
  432.         case GL_TEXTURE_LUMINANCE_SIZE:
  433.            *params = 8;  /* 8-bits */
  434.            break;
  435.         case GL_TEXTURE_INDEX_SIZE_EXT:
  436.            *params = 8;
  437.            break;
  438.         default:
  439.            gl_error( ctx, GL_INVALID_ENUM,
  440.              "glGetTexLevelParameter[if]v(pname)" );
  441.      }
  442.      break;
  443.       case GL_TEXTURE_3D_EXT:
  444.      tex = texSet->Current3D->Image[level];
  445.      if (!tex)
  446.         return;
  447.      switch (pname) {
  448.         case GL_TEXTURE_WIDTH:
  449.            *params = tex->Width;
  450.            break;
  451.         case GL_TEXTURE_HEIGHT:
  452.            *params = tex->Height;
  453.            break;
  454.         case GL_TEXTURE_DEPTH_EXT:
  455.            *params = tex->Depth;
  456.            break;
  457.         case GL_TEXTURE_COMPONENTS:
  458.            /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
  459.            *params = tex->IntFormat;
  460.            break;
  461.         case GL_TEXTURE_BORDER:
  462.            *params = tex->Border;
  463.            break;
  464.         case GL_TEXTURE_INDEX_SIZE_EXT:
  465.            *params = 8;
  466.            break;
  467.         default:
  468.            gl_error( ctx, GL_INVALID_ENUM,
  469.              "glGetTexLevelParameter[if]v(pname)" );
  470.      }
  471.      break;
  472.       case GL_PROXY_TEXTURE_1D:
  473.      tex = ctx->Texture.Proxy1D->Image[level];
  474.      if (!tex)
  475.         return;
  476.      switch (pname) {
  477.         case GL_TEXTURE_WIDTH:
  478.            *params = tex->Width;
  479.            break;
  480.         case GL_TEXTURE_COMPONENTS:
  481.            /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
  482.            *params = tex->IntFormat;
  483.            break;
  484.         case GL_TEXTURE_BORDER:
  485.            *params = tex->Border;
  486.            break;
  487.         case GL_TEXTURE_RED_SIZE:
  488.         case GL_TEXTURE_GREEN_SIZE:
  489.         case GL_TEXTURE_BLUE_SIZE:
  490.         case GL_TEXTURE_ALPHA_SIZE:
  491.         case GL_TEXTURE_INTENSITY_SIZE:
  492.         case GL_TEXTURE_LUMINANCE_SIZE:
  493.            *params = 8;  /* 8-bits */
  494.            break;
  495.         case GL_TEXTURE_INDEX_SIZE_EXT:
  496.            *params = 8;
  497.            break;
  498.         default:
  499.            gl_error( ctx, GL_INVALID_ENUM,
  500.              "glGetTexLevelParameter[if]v(pname)" );
  501.      }
  502.      break;
  503.       case GL_PROXY_TEXTURE_2D:
  504.      tex = ctx->Texture.Proxy2D->Image[level];
  505.      if (!tex)
  506.         return;
  507.      switch (pname) {
  508.         case GL_TEXTURE_WIDTH:
  509.            *params = tex->Width;
  510.            break;
  511.         case GL_TEXTURE_HEIGHT:
  512.            *params = tex->Height;
  513.            break;
  514.         case GL_TEXTURE_COMPONENTS:
  515.            /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
  516.            *params = tex->IntFormat;
  517.            break;
  518.         case GL_TEXTURE_BORDER:
  519.            *params = tex->Border;
  520.            break;
  521.         case GL_TEXTURE_RED_SIZE:
  522.         case GL_TEXTURE_GREEN_SIZE:
  523.         case GL_TEXTURE_BLUE_SIZE:
  524.         case GL_TEXTURE_ALPHA_SIZE:
  525.         case GL_TEXTURE_INTENSITY_SIZE:
  526.         case GL_TEXTURE_LUMINANCE_SIZE:
  527.            *params = 8;  /* 8-bits */
  528.            break;
  529.         case GL_TEXTURE_INDEX_SIZE_EXT:
  530.            *params = 8;
  531.            break;
  532.         default:
  533.            gl_error( ctx, GL_INVALID_ENUM,
  534.              "glGetTexLevelParameter[if]v(pname)" );
  535.      }
  536.      break;
  537.       case GL_PROXY_TEXTURE_3D_EXT:
  538.      tex = ctx->Texture.Proxy3D->Image[level];
  539.      if (!tex)
  540.         return;
  541.      switch (pname) {
  542.         case GL_TEXTURE_WIDTH:
  543.            *params = tex->Width;
  544.            break;
  545.         case GL_TEXTURE_HEIGHT:
  546.            *params = tex->Height;
  547.            break;
  548.         case GL_TEXTURE_DEPTH_EXT:
  549.            *params = tex->Depth;
  550.            break;
  551.         case GL_TEXTURE_COMPONENTS:
  552.            /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
  553.            *params = tex->IntFormat;
  554.            break;
  555.         case GL_TEXTURE_BORDER:
  556.            *params = tex->Border;
  557.            break;
  558.         case GL_TEXTURE_RED_SIZE:
  559.         case GL_TEXTURE_GREEN_SIZE:
  560.         case GL_TEXTURE_BLUE_SIZE:
  561.         case GL_TEXTURE_ALPHA_SIZE:
  562.         case GL_TEXTURE_INTENSITY_SIZE:
  563.         case GL_TEXTURE_LUMINANCE_SIZE:
  564.            *params = 8;  /* 8-bits */
  565.            break;
  566.         case GL_TEXTURE_INDEX_SIZE_EXT:
  567.            *params = 8;
  568.            break;
  569.         default:
  570.            gl_error( ctx, GL_INVALID_ENUM,
  571.              "glGetTexLevelParameter[if]v(pname)" );
  572.      }
  573.      break;
  574.      default:
  575.      gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
  576.    }     
  577. }
  578.  
  579.  
  580.  
  581.  
  582. void gl_GetTexParameterfv( GLcontext *ctx,
  583.                GLenum target, GLenum pname, GLfloat *params )
  584. {
  585.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  586.    struct gl_texture_object *obj;
  587.  
  588.    switch (target) {
  589.       case GL_TEXTURE_1D:
  590.      obj = texSet->Current1D;
  591.      break;
  592.       case GL_TEXTURE_2D:
  593.      obj = texSet->Current2D;
  594.      break;
  595.       case GL_TEXTURE_3D_EXT:
  596.      obj = texSet->Current3D;
  597.      break;
  598.       default:
  599.      gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
  600.      return;
  601.    }
  602.  
  603.    switch (pname) {
  604.       case GL_TEXTURE_MAG_FILTER:
  605.      *params = ENUM_TO_FLOAT(obj->MagFilter);
  606.      break;
  607.       case GL_TEXTURE_MIN_FILTER:
  608.      *params = ENUM_TO_FLOAT(obj->MinFilter);
  609.      break;
  610.       case GL_TEXTURE_WRAP_S:
  611.      *params = ENUM_TO_FLOAT(obj->WrapS);
  612.      break;
  613.       case GL_TEXTURE_WRAP_T:
  614.      *params = ENUM_TO_FLOAT(obj->WrapT);
  615.      break;
  616.       case GL_TEXTURE_WRAP_R_EXT:
  617.      *params = ENUM_TO_FLOAT(obj->WrapR);
  618.      break;
  619.       case GL_TEXTURE_BORDER_COLOR:
  620.      params[0] = obj->BorderColor[0] / 255.0F;
  621.      params[1] = obj->BorderColor[1] / 255.0F;
  622.      params[2] = obj->BorderColor[2] / 255.0F;
  623.      params[3] = obj->BorderColor[3] / 255.0F;
  624.      break;
  625.       case GL_TEXTURE_RESIDENT:
  626.      *params = ENUM_TO_FLOAT(GL_TRUE);
  627.      break;
  628.       case GL_TEXTURE_PRIORITY:
  629.      *params = texSet->Current1D->Priority;
  630.      break;
  631.       case GL_TEXTURE_MIN_LOD:
  632.      *params = obj->MinLod;
  633.      break;
  634.       case GL_TEXTURE_MAX_LOD:
  635.      *params = obj->MaxLod;
  636.      break;
  637.       case GL_TEXTURE_BASE_LEVEL:
  638.      *params = obj->BaseLevel;
  639.      break;
  640.       case GL_TEXTURE_MAX_LEVEL:
  641.      *params = obj->MaxLevel;
  642.      break;
  643.       default:
  644.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
  645.    }
  646. }
  647.  
  648.  
  649. void gl_GetTexParameteriv( GLcontext *ctx,
  650.                GLenum target, GLenum pname, GLint *params )
  651. {
  652.    struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
  653.    struct gl_texture_object *obj;
  654.  
  655.    switch (target) {
  656.       case GL_TEXTURE_1D:
  657.      obj = texSet->Current1D;
  658.      break;
  659.       case GL_TEXTURE_2D:
  660.      obj = texSet->Current2D;
  661.      break;
  662.       case GL_TEXTURE_3D_EXT:
  663.      obj = texSet->Current3D;
  664.      break;
  665.       default:
  666.      gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
  667.      return;
  668.    }
  669.  
  670.    switch (pname) {
  671.       case GL_TEXTURE_MAG_FILTER:
  672.      *params = (GLint) obj->MagFilter;
  673.      break;
  674.       case GL_TEXTURE_MIN_FILTER:
  675.      *params = (GLint) obj->MinFilter;
  676.      break;
  677.       case GL_TEXTURE_WRAP_S:
  678.      *params = (GLint) obj->WrapS;
  679.      break;
  680.       case GL_TEXTURE_WRAP_T:
  681.      *params = (GLint) obj->WrapT;
  682.      break;
  683.       case GL_TEXTURE_WRAP_R_EXT:
  684.      *params = (GLint) obj->WrapR;
  685.      break;
  686.       case GL_TEXTURE_BORDER_COLOR:
  687.      {
  688.         GLfloat color[4];
  689.         color[0] = obj->BorderColor[0]/255.0;
  690.         color[1] = obj->BorderColor[1]/255.0;
  691.         color[2] = obj->BorderColor[2]/255.0;
  692.         color[3] = obj->BorderColor[3]/255.0;
  693.         params[0] = FLOAT_TO_INT( color[0] );
  694.         params[1] = FLOAT_TO_INT( color[1] );
  695.         params[2] = FLOAT_TO_INT( color[2] );
  696.         params[3] = FLOAT_TO_INT( color[3] );
  697.      }
  698.      break;
  699.       case GL_TEXTURE_RESIDENT:
  700.      *params = (GLint) GL_TRUE;
  701.      break;
  702.       case GL_TEXTURE_PRIORITY:
  703.      *params = (GLint) obj->Priority;
  704.      break;
  705.       case GL_TEXTURE_MIN_LOD:
  706.      *params = (GLint) obj->MinLod;
  707.      break;
  708.       case GL_TEXTURE_MAX_LOD:
  709.      *params = (GLint) obj->MaxLod;
  710.      break;
  711.       case GL_TEXTURE_BASE_LEVEL:
  712.      *params = obj->BaseLevel;
  713.      break;
  714.       case GL_TEXTURE_MAX_LEVEL:
  715.      *params = obj->MaxLevel;
  716.      break;
  717.       default:
  718.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
  719.    }
  720. }
  721.  
  722.  
  723.  
  724.  
  725. /**********************************************************************/
  726. /*                    Texture Coord Generation                        */
  727. /**********************************************************************/
  728.  
  729.  
  730. void gl_TexGenfv( GLcontext *ctx,
  731.           GLenum coord, GLenum pname, const GLfloat *params )
  732. {
  733.    GLuint tSet = ctx->Texture.CurrentTransformSet;
  734.    struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
  735.    if (INSIDE_BEGIN_END(ctx)) {
  736.       gl_error( ctx, GL_INVALID_OPERATION, "glTexGenfv" );
  737.       return;
  738.    }
  739.  
  740.    switch( coord ) {
  741.       case GL_S:
  742.      if (pname==GL_TEXTURE_GEN_MODE) {
  743.         GLenum mode = (GLenum) (GLint) *params;
  744.         if (mode==GL_OBJECT_LINEAR ||
  745.         mode==GL_EYE_LINEAR ||
  746.         mode==GL_SPHERE_MAP) {
  747.            texSet->GenModeS = mode;
  748.         }
  749.         else {
  750.            gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
  751.            return;
  752.         }
  753.      }
  754.      else if (pname==GL_OBJECT_PLANE) {
  755.         texSet->ObjectPlaneS[0] = params[0];
  756.         texSet->ObjectPlaneS[1] = params[1];
  757.         texSet->ObjectPlaneS[2] = params[2];
  758.         texSet->ObjectPlaneS[3] = params[3];
  759.      }
  760.      else if (pname==GL_EYE_PLANE) {
  761.         /* Transform plane equation by the inverse modelview matrix */
  762.         if (ctx->NewModelViewMatrix) {
  763.            gl_analyze_modelview_matrix(ctx);
  764.         }
  765.         gl_transform_vector( texSet->EyePlaneS, params,
  766.                  ctx->ModelViewInv );
  767.      }
  768.      else {
  769.         gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
  770.         return;
  771.      }
  772.      break;
  773.       case GL_T:
  774.      if (pname==GL_TEXTURE_GEN_MODE) {
  775.         GLenum mode = (GLenum) (GLint) *params;
  776.         if (mode==GL_OBJECT_LINEAR ||
  777.         mode==GL_EYE_LINEAR ||
  778.         mode==GL_SPHERE_MAP) {
  779.            texSet->GenModeT = mode;
  780.         }
  781.         else {
  782.            gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
  783.            return;
  784.         }
  785.      }
  786.      else if (pname==GL_OBJECT_PLANE) {
  787.         texSet->ObjectPlaneT[0] = params[0];
  788.         texSet->ObjectPlaneT[1] = params[1];
  789.         texSet->ObjectPlaneT[2] = params[2];
  790.         texSet->ObjectPlaneT[3] = params[3];
  791.      }
  792.      else if (pname==GL_EYE_PLANE) {
  793.         /* Transform plane equation by the inverse modelview matrix */
  794.         if (ctx->NewModelViewMatrix) {
  795.            gl_analyze_modelview_matrix(ctx);
  796.         }
  797.         gl_transform_vector( texSet->EyePlaneT, params,
  798.                  ctx->ModelViewInv );
  799.      }
  800.      else {
  801.         gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
  802.         return;
  803.      }
  804.      break;
  805.       case GL_R:
  806.      if (pname==GL_TEXTURE_GEN_MODE) {
  807.         GLenum mode = (GLenum) (GLint) *params;
  808.         if (mode==GL_OBJECT_LINEAR ||
  809.         mode==GL_EYE_LINEAR) {
  810.            texSet->GenModeR = mode;
  811.         }
  812.         else {
  813.            gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
  814.            return;
  815.         }
  816.      }
  817.      else if (pname==GL_OBJECT_PLANE) {
  818.         texSet->ObjectPlaneR[0] = params[0];
  819.         texSet->ObjectPlaneR[1] = params[1];
  820.         texSet->ObjectPlaneR[2] = params[2];
  821.         texSet->ObjectPlaneR[3] = params[3];
  822.      }
  823.      else if (pname==GL_EYE_PLANE) {
  824.         /* Transform plane equation by the inverse modelview matrix */
  825.         if (ctx->NewModelViewMatrix) {
  826.            gl_analyze_modelview_matrix(ctx);
  827.         }
  828.         gl_transform_vector( texSet->EyePlaneR, params,
  829.                  ctx->ModelViewInv );
  830.      }
  831.      else {
  832.         gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
  833.         return;
  834.      }
  835.      break;
  836.       case GL_Q:
  837.      if (pname==GL_TEXTURE_GEN_MODE) {
  838.         GLenum mode = (GLenum) (GLint) *params;
  839.         if (mode==GL_OBJECT_LINEAR ||
  840.         mode==GL_EYE_LINEAR) {
  841.            texSet->GenModeQ = mode;
  842.         }
  843.         else {
  844.            gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
  845.            return;
  846.         }
  847.      }
  848.      else if (pname==GL_OBJECT_PLANE) {
  849.         texSet->ObjectPlaneQ[0] = params[0];
  850.         texSet->ObjectPlaneQ[1] = params[1];
  851.         texSet->ObjectPlaneQ[2] = params[2];
  852.         texSet->ObjectPlaneQ[3] = params[3];
  853.      }
  854.      else if (pname==GL_EYE_PLANE) {
  855.         /* Transform plane equation by the inverse modelview matrix */
  856.         if (ctx->NewModelViewMatrix) {
  857.            gl_analyze_modelview_matrix(ctx);
  858.         }
  859.         gl_transform_vector( texSet->EyePlaneQ, params,
  860.                  ctx->ModelViewInv );
  861.      }
  862.      else {
  863.         gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
  864.         return;
  865.      }
  866.      break;
  867.       default:
  868.      gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" );
  869.      return;
  870.    }
  871.  
  872.    ctx->NewState |= NEW_TEXTURING;
  873. }
  874.  
  875.  
  876.  
  877. void gl_GetTexGendv( GLcontext *ctx,
  878.              GLenum coord, GLenum pname, GLdouble *params )
  879. {
  880.    GLuint tSet = ctx->Texture.CurrentTransformSet;
  881.    struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
  882.    if (INSIDE_BEGIN_END(ctx)) {
  883.       gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGendv" );
  884.       return;
  885.    }
  886.  
  887.    switch( coord ) {
  888.       case GL_S:
  889.      if (pname==GL_TEXTURE_GEN_MODE) {
  890.         params[0] = ENUM_TO_DOUBLE(texSet->GenModeS);
  891.      }
  892.      else if (pname==GL_OBJECT_PLANE) {
  893.         COPY_4V( params, texSet->ObjectPlaneS );
  894.      }
  895.      else if (pname==GL_EYE_PLANE) {
  896.         COPY_4V( params, texSet->EyePlaneS );
  897.      }
  898.      else {
  899.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
  900.         return;
  901.      }
  902.      break;
  903.       case GL_T:
  904.      if (pname==GL_TEXTURE_GEN_MODE) {
  905.         params[0] = ENUM_TO_DOUBLE(texSet->GenModeT);
  906.      }
  907.      else if (pname==GL_OBJECT_PLANE) {
  908.         COPY_4V( params, texSet->ObjectPlaneT );
  909.      }
  910.      else if (pname==GL_EYE_PLANE) {
  911.         COPY_4V( params, texSet->EyePlaneT );
  912.      }
  913.      else {
  914.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
  915.         return;
  916.      }
  917.      break;
  918.       case GL_R:
  919.      if (pname==GL_TEXTURE_GEN_MODE) {
  920.         params[0] = ENUM_TO_DOUBLE(texSet->GenModeR);
  921.      }
  922.      else if (pname==GL_OBJECT_PLANE) {
  923.         COPY_4V( params, texSet->ObjectPlaneR );
  924.      }
  925.      else if (pname==GL_EYE_PLANE) {
  926.         COPY_4V( params, texSet->EyePlaneR );
  927.      }
  928.      else {
  929.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
  930.         return;
  931.      }
  932.      break;
  933.       case GL_Q:
  934.      if (pname==GL_TEXTURE_GEN_MODE) {
  935.         params[0] = ENUM_TO_DOUBLE(texSet->GenModeQ);
  936.      }
  937.      else if (pname==GL_OBJECT_PLANE) {
  938.         COPY_4V( params, texSet->ObjectPlaneQ );
  939.      }
  940.      else if (pname==GL_EYE_PLANE) {
  941.         COPY_4V( params, texSet->EyePlaneQ );
  942.      }
  943.      else {
  944.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
  945.         return;
  946.      }
  947.      break;
  948.       default:
  949.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" );
  950.      return;
  951.    }
  952. }
  953.  
  954.  
  955.  
  956. void gl_GetTexGenfv( GLcontext *ctx,
  957.              GLenum coord, GLenum pname, GLfloat *params )
  958. {
  959.    GLuint tSet = ctx->Texture.CurrentTransformSet;
  960.    struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
  961.    if (INSIDE_BEGIN_END(ctx)) {
  962.       gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGenfv" );
  963.       return;
  964.    }
  965.  
  966.    switch( coord ) {
  967.       case GL_S:
  968.      if (pname==GL_TEXTURE_GEN_MODE) {
  969.         params[0] = ENUM_TO_FLOAT(texSet->GenModeS);
  970.      }
  971.      else if (pname==GL_OBJECT_PLANE) {
  972.         COPY_4V( params, texSet->ObjectPlaneS );
  973.      }
  974.      else if (pname==GL_EYE_PLANE) {
  975.         COPY_4V( params, texSet->EyePlaneS );
  976.      }
  977.      else {
  978.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
  979.         return;
  980.      }
  981.      break;
  982.       case GL_T:
  983.      if (pname==GL_TEXTURE_GEN_MODE) {
  984.         params[0] = ENUM_TO_FLOAT(texSet->GenModeT);
  985.      }
  986.      else if (pname==GL_OBJECT_PLANE) {
  987.         COPY_4V( params, texSet->ObjectPlaneT );
  988.      }
  989.      else if (pname==GL_EYE_PLANE) {
  990.         COPY_4V( params, texSet->EyePlaneT );
  991.      }
  992.      else {
  993.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
  994.         return;
  995.      }
  996.      break;
  997.       case GL_R:
  998.      if (pname==GL_TEXTURE_GEN_MODE) {
  999.         params[0] = ENUM_TO_FLOAT(texSet->GenModeR);
  1000.      }
  1001.      else if (pname==GL_OBJECT_PLANE) {
  1002.         COPY_4V( params, texSet->ObjectPlaneR );
  1003.      }
  1004.      else if (pname==GL_EYE_PLANE) {
  1005.         COPY_4V( params, texSet->EyePlaneR );
  1006.      }
  1007.      else {
  1008.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
  1009.         return;
  1010.      }
  1011.      break;
  1012.       case GL_Q:
  1013.      if (pname==GL_TEXTURE_GEN_MODE) {
  1014.         params[0] = ENUM_TO_FLOAT(texSet->GenModeQ);
  1015.      }
  1016.      else if (pname==GL_OBJECT_PLANE) {
  1017.         COPY_4V( params, texSet->ObjectPlaneQ );
  1018.      }
  1019.      else if (pname==GL_EYE_PLANE) {
  1020.         COPY_4V( params, texSet->EyePlaneQ );
  1021.      }
  1022.      else {
  1023.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
  1024.         return;
  1025.      }
  1026.      break;
  1027.       default:
  1028.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" );
  1029.      return;
  1030.    }
  1031. }
  1032.  
  1033.  
  1034.  
  1035. void gl_GetTexGeniv( GLcontext *ctx,
  1036.              GLenum coord, GLenum pname, GLint *params )
  1037. {
  1038.    GLuint tSet = ctx->Texture.CurrentTransformSet;
  1039.    struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
  1040.    if (INSIDE_BEGIN_END(ctx)) {
  1041.       gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGeniv" );
  1042.       return;
  1043.    }
  1044.  
  1045.    switch( coord ) {
  1046.       case GL_S:
  1047.      if (pname==GL_TEXTURE_GEN_MODE) {
  1048.         params[0] = texSet->GenModeS;
  1049.      }
  1050.      else if (pname==GL_OBJECT_PLANE) {
  1051.         COPY_4V( params, (GLint) texSet->ObjectPlaneS );
  1052.      }
  1053.      else if (pname==GL_EYE_PLANE) {
  1054.         COPY_4V( params, (GLint) texSet->EyePlaneS );
  1055.      }
  1056.      else {
  1057.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
  1058.         return;
  1059.      }
  1060.      break;
  1061.       case GL_T:
  1062.      if (pname==GL_TEXTURE_GEN_MODE) {
  1063.         params[0] = texSet->GenModeT;
  1064.      }
  1065.      else if (pname==GL_OBJECT_PLANE) {
  1066.         COPY_4V( params, (GLint) texSet->ObjectPlaneT );
  1067.      }
  1068.      else if (pname==GL_EYE_PLANE) {
  1069.         COPY_4V( params, (GLint) texSet->EyePlaneT );
  1070.      }
  1071.      else {
  1072.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
  1073.         return;
  1074.      }
  1075.      break;
  1076.       case GL_R:
  1077.      if (pname==GL_TEXTURE_GEN_MODE) {
  1078.         params[0] = texSet->GenModeR;
  1079.      }
  1080.      else if (pname==GL_OBJECT_PLANE) {
  1081.         COPY_4V( params, (GLint) texSet->ObjectPlaneR );
  1082.      }
  1083.      else if (pname==GL_EYE_PLANE) {
  1084.         COPY_4V( params, (GLint) texSet->EyePlaneR );
  1085.      }
  1086.      else {
  1087.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
  1088.         return;
  1089.      }
  1090.      break;
  1091.       case GL_Q:
  1092.      if (pname==GL_TEXTURE_GEN_MODE) {
  1093.         params[0] = texSet->GenModeQ;
  1094.      }
  1095.      else if (pname==GL_OBJECT_PLANE) {
  1096.         COPY_4V( params, (GLint) texSet->ObjectPlaneQ );
  1097.      }
  1098.      else if (pname==GL_EYE_PLANE) {
  1099.         COPY_4V( params, (GLint) texSet->EyePlaneQ );
  1100.      }
  1101.      else {
  1102.         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
  1103.         return;
  1104.      }
  1105.      break;
  1106.       default:
  1107.      gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" );
  1108.      return;
  1109.    }
  1110. }
  1111.  
  1112.  
  1113.  
  1114. /* GL_SGIS_multitexture */
  1115. void gl_SelectTextureSGIS( GLcontext *ctx, GLenum target )
  1116. {
  1117.    GLint texSet;
  1118.    GLint maxSets = gl_max_texture_coord_sets(ctx);
  1119.    if (target >= GL_TEXTURE0_SGIS && target < GL_TEXTURE0_SGIS + maxSets) {
  1120.       texSet = target - GL_TEXTURE0_SGIS;
  1121.       /* Select current texture env AND transformation set! */
  1122.       ctx->Texture.CurrentSet = texSet;
  1123.       ctx->Texture.CurrentTransformSet = texSet;
  1124.    }
  1125.    else {
  1126.       gl_error(ctx, GL_INVALID_OPERATION, "glSelectTextureSGIS(target)");
  1127.       return;
  1128.    }
  1129. }
  1130.  
  1131.  
  1132. /* GL_EXT_multitexture */
  1133. void gl_SelectTexture( GLcontext *ctx, GLenum target )
  1134. {
  1135.    GLint texSet;
  1136.    GLint maxSets = gl_max_texture_coord_sets(ctx);
  1137.    if (target >= GL_TEXTURE0_EXT && target < GL_TEXTURE0_EXT + maxSets) {
  1138.       texSet = target - GL_TEXTURE0_EXT;
  1139.    }
  1140.    else {
  1141.       gl_error(ctx, GL_INVALID_OPERATION, "glSelectTexture(target)");
  1142.       return;
  1143.    }
  1144.    ctx->Texture.CurrentSet = texSet;
  1145. }
  1146.  
  1147.  
  1148.  
  1149. /* GL_SGIS_multitexture / GL_EXT_multitexture */
  1150. void gl_SelectTextureCoordSet( GLcontext *ctx, GLenum target )
  1151. {
  1152.    GLint texSet;
  1153.    GLint maxSets = gl_max_texture_coord_sets(ctx);
  1154.    if (target >= GL_TEXTURE0_SGIS && target < GL_TEXTURE0_SGIS + maxSets) {
  1155.       texSet = target - GL_TEXTURE0_SGIS;
  1156.    }
  1157.    else if (target >= GL_TEXTURE0_EXT && target < GL_TEXTURE0_EXT + maxSets) {
  1158.       texSet = target - GL_TEXTURE0_EXT;
  1159.    }
  1160.    else {
  1161.       gl_error(ctx, GL_INVALID_OPERATION, "glSelectTextureCoordSet(target)");
  1162.       return;
  1163.    }
  1164.    ctx->TexCoordSet = texSet;
  1165.    ctx->Current.TexCoord = ctx->Current.MultiTexCoord[texSet];
  1166. }
  1167.  
  1168.  
  1169.  
  1170. /* GL_EXT_multitexture */
  1171. void gl_SelectTextureTransform( GLcontext *ctx, GLenum target )
  1172. {
  1173.    GLint texSet;
  1174.    GLint maxSets = gl_max_texture_coord_sets(ctx);
  1175.    if (target >= GL_TEXTURE0_EXT && target < GL_TEXTURE0_EXT + maxSets) {
  1176.       texSet = target - GL_TEXTURE0_EXT;
  1177.       ctx->Texture.CurrentTransformSet = texSet;
  1178.    }
  1179.    else {
  1180.       gl_error(ctx, GL_INVALID_ENUM, "glSelectTextureTransform(target)");
  1181.       return;
  1182.    }
  1183. }
  1184.  
  1185.  
  1186.  
  1187.  
  1188. /*
  1189.  * This is called by gl_update_state() if the NEW_TEXTURING bit in
  1190.  * ctx->NewState is set.
  1191.  */
  1192. void gl_update_texture_state( GLcontext *ctx )
  1193. {
  1194.    struct gl_texture_object *t;
  1195.    GLuint texSet;
  1196.  
  1197.    for (texSet=0; texSet<MAX_TEX_SETS; texSet++) {
  1198.       GLuint setShift = texSet * 4;
  1199.       if (ctx->Texture.Enabled & (TEXTURE0_3D << setShift))
  1200.      ctx->Texture.Set[texSet].Current = ctx->Texture.Set[texSet].Current3D;
  1201.       else if (ctx->Texture.Enabled & (TEXTURE0_2D << setShift))
  1202.      ctx->Texture.Set[texSet].Current = ctx->Texture.Set[texSet].Current2D;
  1203.       else if (ctx->Texture.Enabled & (TEXTURE0_1D << setShift))
  1204.      ctx->Texture.Set[texSet].Current = ctx->Texture.Set[texSet].Current1D;
  1205.       else
  1206.      ctx->Texture.Set[texSet].Current = NULL;
  1207.    }
  1208.  
  1209.    if (ctx->Texture.AnyDirty) {
  1210.       for (t = ctx->Shared->TexObjectList; t; t = t->Next) {
  1211.      if (t->Dirty) {
  1212.         gl_test_texture_object_completeness(t);
  1213.         gl_set_texture_sampler(t);
  1214.         t->Dirty = GL_FALSE;
  1215.      }
  1216.       }
  1217.       ctx->Texture.AnyDirty = GL_FALSE;
  1218.    }
  1219. }
  1220.